package cn.hjh.service;

import cn.hjh.dao.HibernateUtil;
import cn.hjh.dao.HouseDao;
import cn.hjh.dao.UsersDao;
import cn.hjh.pojo.House;
import cn.hjh.pojo.Users;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;

import java.util.List;

public class HouseBiz {

    HouseDao houseDao = new HouseDao();

    /* 查询中关村地区面积大于80cm的房屋信息 */
    public List<House> findByHouse(){
        Transaction tx = null;
        List<House> houses = null;
        try {
            tx = HibernateUtil.currentSession().beginTransaction();
            houses = houseDao.findByHouse();
            tx.commit();
        } catch (HibernateException e) {
            e.printStackTrace();
            if (tx != null)
                tx.rollback();
        }
        return houses;
    }

    public List<House> findHouseByPage(int pageNo, int pageSize){
        Transaction tx = null;
        List<House> houses = null;
        try {
            tx = HibernateUtil.currentSession().beginTransaction();
            houses = new HouseBiz().findHouseByPage(pageNo,pageSize);
            tx.commit();
        } catch (HibernateException e) {
            e.printStackTrace();
            if (tx != null)
                tx.rollback();
        }
        return houses;
    }
}
